package com.wch.demo.actuator;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.metrics.CounterService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 自定义测试autuator内部分内容
 * @author WanChengHe 20200509
 *
 */
@Controller
@RequestMapping("/testActuator")
public class StandandController {
	
	@Autowired
	private CounterService counterService;
	
	
	/**
	 * 自定义实现对/greet接口的访问次数统计
	 * 预期结果：访问该接口后再查看metrics路径 有 ："counter.wch.greet.count":1
	 * @return
	 */
	@RequestMapping("/greet")
	public String greet(){
		counterService.increment("wch.greet.count");
		return "1";
	}

}
